﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SDT.Model
{
    public class VideoManager
    {
        public static IList<Comment> GetComments(int id, bool? publishYN, int number)
        {
            var dataContext = new SDTDataContext();
            var l = (from c in dataContext.Comments
                     from m in dataContext.CommentsInVideos
                     where c.ID == m.CommentID && m.VideoID == id && (publishYN == null ? true : c.PublishYN == publishYN)
                     orderby c.ID descending
                     select c).Take(number).ToList();
            return l;
        }
        public static Video GetVideo(int videoId)
        {
            var db = new SDTDataContext();
            return db.Videos.SingleOrDefault(a => a.ID == videoId);
        }
    }
}
